<div id="admin">
  <div class="container content_box clearfix">

  <%= render 'admin/header', active: 'campaigns' %>

    <div id="admin_campaigns">

      <table class="table table-striped">
        <tr>
          <th>Name</th>
          <th>Goal</th>
          <th>Raised</th>
          <th>Expiration<br/>Date</th>
          <th>Published?</th>
          <th>Payments<br/>Activated?</th>
          <th></th>
          <th></th>
          <th></th>
          <th></th>
        </tr>

      <% @campaigns.each do |campaign| %>
        <tr>
          <td><%= campaign.name %></td>

          <td>
            <% if campaign.goal_type == "dollars" %>
              <%= short_price(campaign.goal_dollars.to_f, '$', 2) %>
            <% else %>
              <%= campaign.goal_orders %>
            <% end %>
          </td>
          <td>
            <% if campaign.goal_type == "dollars" %>
              <%= short_price(campaign.stats_raised_amount.to_f, '$', 2) %>
            <% else %>
              <%= campaign.orders %>
            <% end %>
          </td>

          <td><%= Date.parse(campaign.expiration_date.to_s).strftime("%m/%d/%Y") %></td>
          <td><%= campaign.published_flag ? raw('<i class="icon-ok"></i>') : '' %></td>
          <td><%= campaign.production_flag ? raw('<i class="icon-ok"></i>') : '' %></td>
          <td><%= link_to 'Edit', edit_admin_campaign_path(campaign) %></td>
          <td><%= link_to 'View', campaign_home_path(campaign) %></td>
          <td><%= link_to 'Payments', admin_campaigns_payments_path(campaign) %></td>
          <td><%= link_to 'Copy', admin_campaigns_copy_path(campaign) %></td>
        </tr>
      <% end %>
      </table>

      <br />

      <%= link_to 'New Campaign', new_admin_campaign_path %>
    </div>
  </div>
</div>

<% if flash[:signup_modal] %>
<div class="modal hide fade" id="signupModal">
  <div class="modal-header">
    <a class="close" data-dismiss="modal">×</a>
    <h3>Your page is almost ready!</h3>
  </div>
  <div class="modal-body">
    <p>Start out by creating your first campaign.</p>
    <p>If you have any questions as you get started, reach out to us: <a href="mailto:open@tilt.com?subject=I%20have%20questions%20about%20getting%20started%20with%20Tilt%20Open">open@tilt.com</a>.</p>
  </div>
  <div class="modal-footer">
    <a href="#" class="btn" data-dismiss="modal">Close</a>
    <a href="<%= new_admin_campaign_path %>" class="btn btn-primary">Start campaign!</a>
  </div>
</div>

<% content_for :scripts do %>
<script type="text/javascript">
    $(window).load(function(){
        $('#signupModal').modal('show');
    });
</script>
<% end %>

<% end %>
